import { IPSAppView } from '../app/view/ipsapp-view';
import { IPSControlObjectNavigatable } from './ipscontrol-object-navigatable';
import { IPSNavigateContext } from './ipsnavigate-context';
import { IPSNavigateParam } from './ipsnavigate-param';
import { PSControlObjectImpl } from './pscontrol-object-impl';
import { IPSDERBase } from '../dataentity/der/ipsderbase';

export class PSControlObjectImpl2 extends PSControlObjectImpl implements IPSControlObjectNavigatable {
  get navFilter(): string {
    return this.M.navFilter;
  }

  protected navpsappview: IPSAppView | null = null;

  getNavPSAppView(): IPSAppView | null {
    if (this.navpsappview != null) return this.navpsappview;
    const value = this.M.getNavPSAppView;
    if (value == null) {
      return null;
    }
    this.navpsappview = this.getPSModel4('app.view.IPSAppView', value, 'getNavPSAppView') as IPSAppView;
    return this.navpsappview;
  }

  get navPSAppView(): IPSAppView | null {
    return this.getNavPSAppView();
  }

  getNavPSAppViewMust(): IPSAppView {
    const value = this.getNavPSAppView();
    if (value == null) {
      throw new Error('未指定导航视图对象');
    }
    return value;
  }

  protected navpsder: IPSDERBase | null = null;

  getNavPSDER(): IPSDERBase | null {
    if (this.navpsder != null) return this.navpsder;
    const value = this.M.getNavPSDER;
    if (value == null) {
      return null;
    }
    this.navpsder = this.getPSModel4('dataentity.der.IPSDERBase', value, 'getNavPSDER') as IPSDERBase;
    return this.navpsder;
  }

  get navPSDER(): IPSDERBase | null {
    return this.getNavPSDER();
  }

  getNavPSDERMust(): IPSDERBase {
    const value = this.getNavPSDER();
    if (value == null) {
      throw new Error('未指定导航关系');
    }
    return value;
  }

  get navViewParamJO(): IModel {
    return this.M.navViewParamJO;
  }

  protected psnavigatecontexts: IPSNavigateContext[] | null = null;

  getPSNavigateContexts(): IPSNavigateContext[] | null {
    if (this.psnavigatecontexts == null) {
      this.psnavigatecontexts = this.fillChildListModel(this.M.getPSNavigateContexts, 'control.IPSNavigateContext') as IPSNavigateContext[];
    }
    return this.psnavigatecontexts;
  }

  get psNavigateContexts(): IPSNavigateContext[] | null {
    return this.getPSNavigateContexts();
  }

  findPSNavigateContext(objKey: any): IPSNavigateContext | null {
    return this.getPSModel5('control.IPSNavigateContext', this.getPSNavigateContexts(), objKey) as IPSNavigateContext;
  }

  protected psnavigateparams: IPSNavigateParam[] | null = null;

  getPSNavigateParams(): IPSNavigateParam[] | null {
    if (this.psnavigateparams == null) {
      this.psnavigateparams = this.fillChildListModel(this.M.getPSNavigateParams, 'control.IPSNavigateParam') as IPSNavigateParam[];
    }
    return this.psnavigateparams;
  }

  get psNavigateParams(): IPSNavigateParam[] | null {
    return this.getPSNavigateParams();
  }

  findPSNavigateParam(objKey: any): IPSNavigateParam | null {
    return this.getPSModel5('control.IPSNavigateParam', this.getPSNavigateParams(), objKey) as IPSNavigateParam;
  }

  get cls(): string {
    return 'PSControlObjectImpl2';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.IPSControlObjectNavigatable' || cls == 'control.IPSNavigatable' || cls == 'control.IPSNavigateParamContainer') return true;
    return super.instanceof(cls);
  }
}
